Short Communication TYPE-SAFE CASTING
نویسندگان
چکیده
types cannot be cast, because their representations are unknown. We can cast an lvalue from a visible type T1 to another visible typeT2when all of the following conditions hold: Every bit pattern that represents a legal value in T1 represents a legal value in T2 . If the lvalue is writable, every bit pattern that represents a legal value in T2 must represent a legal value in T1 . The use of the lvalue must satisfy the constraints of the underlying architecture. For example, we disallow casts between floating point and integer lvalues. Such casts might not preserve sharing if the lvalues were assigned to registers because the integer and floating point register sets are disjoint. The use of the lvalue must satisfy the code generation constraints of the compiler and architecture. For example, the alignment of the lvalue may have to satisfy the alignment required for T2. Reasoning about the bit representation of types is straightforward (although compilerand languagedependent): For a base non-pointer type, the set of legal bit representations is defined by the language implementation. For a pointer type, the set of legal representations is distinct from all other types. For a record or array type, the set of legal representations is a combination of the bit representations of the types of the fields (which must include any padding). This definition assumes that the constituents of a record or array as well as any padding are laid out according to a well-known, deterministic algorithm (as defined by the language or compiler). Our casting operator is type-safe for two reasons. First, the conditions for legal casting guarantee that our cast does not create any illegal representations. Second, there is no harm in allowing application-provided code to “create” new instances of a visible type T via casting. Since T is a visible type, a client can allocate and modify its own instances the type anyway, so no protection is lost. For the sake of exposition, we have assumed that the lvalue has the same size as T2. Nevertheless, the lvalue can be larger thanT2 , in which case it is effectively truncated by the cast. (Our notion of representation equivalence can be easily modified to account for truncation.) This feature is useful for looking at network packets, where networking code needs to examine only the first few bytes of a packet. For a dynamically sized lvalue, such as an array, the size of the lvalue must be checked at runtime to guarantee that the lvalue is at least as large as T2 .
منابع مشابه
A Hybrid Modeling for Continuous Casting Scheduling Problem
This paper deals with a multi-agent-based interval type-2 fuzzy (IT2F) expert systemfor scheduling steel continuous casting. Continuous caster scheduling is a complex and extensiveprocess that needs expert staff. In this study, a distributed multi-agent-based structure is proposed as asolution. The agents used herein can cooperate with each other via various communication protocols.To facilitat...
متن کاملP-V-L Deep: A Big Data Analytics Solution for Now-casting in Monetary Policy
The development of new technologies has confronted the entire domain of science and industry with issues of big data's scalability as well as its integration with the purpose of forecasting analytics in its life cycle. In predictive analytics, the forecast of near-future and recent past - or in other words, the now-casting - is the continuous study of real-time events and constantly updated whe...
متن کاملThe Effect of Type and Concentration of Surfactant and Ligand on Uranium (VI) Cloud-Point Extraction (CPE) from Aqueous Solutions (Short Communication)
In this article cloud-point extraction (CPE) was used with chelating agent to extract uranium from aqueous solutions. The methodology used is based on the formation of metal complexes soluble in a micellar phase of surfactant. The metal ions complexes are then extracted into the surfactant-rich phase at a temperature above the cloud-point temperature. The effect of type of surfactants and ligan...
متن کاملSmart Card Applications and Mobility in a World of Short Distance Communication CASTING Project a cooperation between ETH Zürich, Distributed Systems Group and Swisscom AG Bern, Corporate Technology
The CASTING project is concerned with the application of smart card technology in combination with short distance wireless communication. This report focuses on secure access to Web pages, meaning that the right person has access to his or her personal Web pages in a manner that respects integrity, authenticity and confidentiality. This requires authentication of users, which is achieved by pro...
متن کاملOptimization of the chemical milling of investment cast titanium alloys
Investment casting is a popular casting technique for manufacturing of several titanium alloy components dedicated to different industrial applications, as aerospace and automotive. This manufacturing process could be an economic net-shape technology, since the investment casting allows obtaining complex shapes, accurate geometries and reduced thicknesses. However, the reactions between titaniu...
متن کامل